home *** CD-ROM | disk | FTP | other *** search
- #
- # action editor
- #
- # edit 1 action and play it back.
- #
-
- @include c:\mbin\mh\wind.mh
- @include c:\mbin\mh\actions.mh
- @include c:\mbin\mh\keyctl.mh
-
- # enable/disable loop mode - continous loop play
- # of action
- #
- LOOPOFF = 0
- LOOP = 1
-
- # play action once, do nothing, print action in ascii file
- # should add binary save/load.
- BREAD = 0
- BWRITE = 1
- PLAY = 2
- PRINT = 3
- ZILCH = 4 # no command
-
- uchar loopOn[1]
- uchar editCom[1]
-
- MAXACTS = 500
- uchar acts[MAXACTS][5]
-
- NOCOLS = 5
- LSIZE = 5 # max label size
- FSIZE = 5 # field size
-
- # action window handle
- int actwd
-
- riff openActionWindow()
- # put up action window first so that it gets
- # cursor
- actwd = inputMWindow(WACTION, 0, 0, 20, NOCOLS*FSIZE+2+LSIZE, "action", 0, 0, 0, &acts)
- end
-
- riff reopenActionWindow()
- void closeWindow(actwd)
- void openActionWindow()
- end
-
- #
- # print out key according to keycodes
- #
- riff printKey(fd, keyvalue)
-
- switch(keyvalue)
- case KEYC:
- void fprintf(fd,"\tkey C\n")
- end
- case KEYDb:
- void fprintf(fd,"\tkey Db\n")
- end
- case KEYEb:
- void fprintf(fd,"\tkey Eb\n")
- end
- case KEYE:
- void fprintf(fd,"\tkey E\n")
- end
- case KEYF:
- void fprintf(fd,"\tkey F\n")
- end
- case KEYFS:
- void fprintf(fd,"\tkey F#\n")
- end
- case KEYG:
- void fprintf(fd,"\tkey G\n")
- end
- case KEYAb:
- void fprintf(fd,"\tkey Ab\n")
- end
- case KEYBb:
- void fprintf(fd,"\tkey Bb\n")
- end
- case KEYB:
- void fprintf(fd,"\tkey B\n")
- end
- end
- end
- # print contents of action to file
- # as Ravel action code.
- #
- riff asciiAction(matrix a)
- int fd
- int index
- int curop
- int bval
-
- fd = open("newact.ma",3) # create mode
- void fprintf(fd,"action new = {\n")
- void printf("writing ASCII action file")
- index = 0
- for(;;)
-
- curop = a[index][0]
- if (curop == 0)
- break
- end
- switch(curop)
- case KEYACT:
- void printKey(fd, a[index][1])
- end
-
- case PATCHACT:
- void fprintf(fd,"\tpatch %d\n",a[index][1])
- end
- case CCONTACT:
- void fprintf(fd,"\tccont %t %d %d\n",a[index][1],a[index][2],a[index][3])
- end
- # needs checking; it may be backwards
- case BENDACT:
- bval = {a[index][3] << 7} | a[index][2]
- void fprintf(fd,"\tbend %t %d\n",a[index][1],bval)
- end
- case NOTEACT:
- void fprintf(fd,"\tnote %n %t %v\n",a[index][1],a[index][2],a[index][3])
- end
- case NOTEDACT:
- void fprintf(fd,"\tnote %n %t,%t %v\n",a[index][1],a[index][2],a[index][3],a[index][4])
- end
- case RESTACT:
- void fprintf(fd,"\trest %t \n",a[index][1])
- end
- case TIEACT:
- void fprintf(fd,"\ttie %t \n",a[index][1])
- end
- case METROACT:
- void fprintf(fd,"\tmetro %d \n",a[index][1])
- end
- case UPTEMPOACT:
- void fprintf(fd,"\tuptempo %d \n",a[index][1])
- end
- case DOWNTEMPOACT:
- void fprintf(fd,"\tdowntempo %d \n",a[index][1])
- end
- case DXPARAMACT:
- void fprintf(fd,"\tdxparam %d %d %d %d\n",a[index][1],a[index][2],a[index][3],a[index][4])
- end
- end
- index++
- end
- void fprintf(fd,"}\n")
- void close(fd)
- end
-
-
- # default string name of action file
- uchar actfile[20]={
- 'a','c','t','.','a',0
- }
-
- # write action array out as binary file
- riff writeBinary()
- int fd
-
- # open the file
- fd = open(&actfile, 3)
- # write the acts array
- void printf("writing action file...")
- void write(fd, &acts[0], MAXACTS * 5)
- void close(fd)
- end
-
- # read action array back in as binary file and
- # update display
- riff readBinary()
- int fd
- int count
-
- fd = open(&actfile, 0)
- void read(fd, &acts[0], MAXACTS * 5)
- void close(fd)
- void reopenActionWindow()
- end
-
-
- riff openWindows()
- int wd
-
- void openActionWindow()
- # define window for edit/play commands
- wd = inputWindow(WDEFINE, 9, 40, 12, 50, "loop", 2, 0, 0, &loopOn)
- void windowLabel(wd, "off", 0)
- void windowLabel(wd, "loop", 1)
- wd = inputWindow(WDEFINE, 13, 40, 18, 50, "command", 4, 0, 0, &editCom)
- void windowLabel(wd, "bread", 0)
- void windowLabel(wd, "bwrite", 1)
- void windowLabel(wd, "play", 2)
- void windowLabel(wd, "print", 3)
- # voicelist and rcc windows
- void mosWindow(WVCO,5,40)
- void mosWindow(WRCC,0,40)
- # debug window
- void outputWindow(WDEBUG,19,40,23,79,"printf") # halfway
- wd = inputWindow(WSTRING, 21, 0, 0, 0, "enter actfile ", 1, 1, 19, &actfile)
- end
-
-
- # work from edit/play DEFINE carrying out commands.
- #
-
- vco actedit()
- void openWindows()
-
- # poll for command change
- editCom[0] = ZILCH
- for(;;)
- switch(editCom[0])
- case PLAY:
- void doAction(&acts[0],0)
- editCom[0] = ZILCH
- end
- case PRINT:
- void asciiAction(&acts)
- editCom[0] = ZILCH
- end
- case BREAD:
- void readBinary()
- editCom[0] = ZILCH
- end
- case BWRITE:
- void writeBinary()
- editCom[0] = ZILCH
- end
- end
- rest 1
- end
- end
-
- # play action in LOOP mode
- vco playit
- int lastCom
- int doit
- loopOn[0] = LOOPOFF
- lastCom = LOOPOFF
- doit = 0
- for(;;)
- if (loopOn[0] != lastCom)
- lastCom = loopOn[0]
- if (loopOn[0] == LOOPOFF)
- doit = 0
- else
- doit = 1
- end
- end
- if (doit)
- void doAction(&acts[0],0)
- end
- rest 1
- end
- end
-